package com.hbnu.system.controller;


import com.hbnu.system.core.base.Rest;
import com.hbnu.system.model.entity.Reportauthor;
import com.hbnu.system.service.IReportauthorService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2023-05-16
 */
@RestController
@RequestMapping("/reportauthor")
@Api(tags = "报告的作者管理")
public class ReportauthorController {

    @Autowired
    private IReportauthorService iReportauthorService;
    @ApiOperation("新增报告作者")
    @PostMapping("/addreportauthor")
    public Rest<String> addreportAuthor(@RequestBody Reportauthor reportauthor){
        boolean ba = iReportauthorService.addReportAuthor(reportauthor);
        return ba ? Rest.success() : Rest.failed();
    }

    @ApiOperation("删除作者信息")
    @GetMapping("/deletereportauthor")
    public Rest<String> deletereport(String id){
        boolean ba1 = iReportauthorService.deleteReportAuthor(id);
        return ba1?Rest.success():Rest.failed();
    }
    @ApiOperation("修改作者信息")
    @PostMapping("/updatereportauthor")
    public Rest<String> updatereportAuthor(@RequestBody Reportauthor reportauthor){
        boolean ba2=iReportauthorService.updateReportAuthor(reportauthor);
        return ba2?Rest.success():Rest.failed();
    }
    @ApiOperation("搜索作者信息")
    @GetMapping("/selectreportauthor")
    public Rest<List<Reportauthor>> selectreportAuthor(String id){
        List<Reportauthor> pa=iReportauthorService.pagereportauthor(id);
        return Rest.success(pa,pa.size());
    }
}

